
public class StringsE3 {

    /**
     * @param args
     */
    public static void main(String[] args) {

        String s = "We are living in a yellow submarine. We don't have anything else. Inside the submarine is very tight. So we are drinking all the day. We will move out of it in 5 days.";
        s = s.toLowerCase();
        int index = s.indexOf("in",0);
        int counter = 0;
        while (index != -1) {
            counter++;
            index = s.indexOf("in",index+1);
        }
        System.out.println("found it " + counter + " times");
    }

}
